<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('学生列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>登录账号：</label>
                            <input type="text" name="loginName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="wstudy:student:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="wstudy:student:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="wstudy:student:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="wstudy:student:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('wstudy:student:edit')}]];
    var removeFlag = [[${@permission.hasPermi('wstudy:student:remove')}]];
    var poorDatas = [[${@dict.getType('wst_student_poor')}]];
    var specialtypeDatas = [[${@dict.getType('wst_student_specialtype')}]];
    var prefix = ctx + "wstudy/student";

    let userId = [[${userId}]]
    let status = "ON"
    $(function() {
        var options = {
            url: prefix + "/list/0"+"/"+userId+"/"+status,
            modalName: "学生",
            columns: [{
                checkbox: true
            },
                {
                    field: 'studentId',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'postId',
                    title: 'postId',
                    visible: false
                },
                {
                    field: 'loginName',
                    title: '账号',
                },
                {
                    field: 'userName',
                    title: '名称',
                },
                {
                    field: 'poor',
                    title: '贫困等级',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(poorDatas, value);
                    }
                },
                {
                    field: 'specialtype',
                    title: '特殊群体类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(specialtypeDatas, value);
                    }
                },
                {
                    field: 'credit',
                    title: '信用分'
                },
                // {
                //     field: 'deductpoints',
                //     title: '扣分'
                // },
                {
                    field: 'status',
                    title: '状态',
                    visible: false
                },
                {
                    field: 'profession',
                    title: '专业'
                },
                {
                    field: 'grade',
                    title: '班级'
                },
                {
                    field: 'post.postName',
                    title: '岗位名称'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        console.log(row)
                        actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="details(\'' + row.studentId + '\')"><i class="fa fa-search"></i>详情</a> ');
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="evaluateScore(\'' + row.studentId + '\')"><i class="fa fa-edit"></i>评分</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="dismissal(\'' + row.studentId+'\',\''+row.postId + '\')"><i class="fa fa-remove"></i>清退</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function details(id) {
        $.modal.openTab("详情",prefix+"/details/"+id);
    }
    function dismissal(studentId,postId) {
        $.modal.confirm("确定清退吗？",function () {
            let url = "/wstudy/process/dismissal";
            let params = {
                postId:postId,
                userId:studentId,
                status:'OFF'
            }
            $.operate.post(url,params);
        });
    }
    function evaluateScore(studentId) {
        let url='/wstudy/credit/evaluate_add/'+studentId;
        $.modal.open("评价",url);
    }
</script>
</body>
</html>